<template>
    <div>
        <h1>登录</h1>
        <table>
            <thead>
                <tr>
                    <td>用户名</td>
                    <td>
                        <input type="text" v-model="data.Uname">
                    </td>
                </tr>
                <tr>
                    <td>用户密码</td>
                    <td>
                        <input type="text" v-model="data.Uimima">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" @click="deng">
                    </td>
                </tr>

            </thead>
        </table>
    </div>
    <a href="/zhuce">注册</a>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
import { useuserStore } from '@/stores/useinfo';
const user=useuserStore();
//实例化
const router=useRouter();

const data=ref({
    Uname:"",
    Uimima:""
});
const deng=()=>{
    axios.get("https://localhost:7293/api/Fhall/Longin",{params:data.value}).then(res=>{
        if(res.data.DId==-1)
        {
            alert("用户不存在");
        }
        if(res.data.DId==-2)
        {
            alert("密码错误");
        }
        if(res.data.DId>0)
        {
            alert("登陆成功");
            user.useinfo.name=data.value.Uname;
            router.push({path:"/"});
        }
    })
}





</script>

<style scoped>

</style>